#include <stdio.h>
#include <stdlib.h>

long long int sum = 0;
int m = 0;
void hanoi(char x, char y, char z, int num)
{
    if (num == 1)
    {
        sum++;
        if (sum == m)
        {
            printf("#%d: %c -> %c\n", num, x, z);
        }
    }
    else
    {
        hanoi(x, z, y, num - 1);
        sum++;
        if (sum == m)
        {
            printf("#%d: %c->%c\n", num, x, z);
        }
        hanoi(y, x, z, num - 1);
    }
}

int main(int argc, char* argv[])
{
    int n = 0;
    scanf("%d %d", &n, &m);
    hanoi('A', 'B', 'C', n);
    printf("%lld", sum);

    return 0;
}